local tiancaijinfeng = fk.CreateSkill{
  name = "tiancaijinfeng",
}

Fk:loadTranslationTable{
  ["tiancaijinfeng"] = "天裁",
  [":tiancaijinfeng"] = "回合结束时，你可以选择一名其他角色，令其获得一个额外的回合。",
  ["#tiancaijinfeng"] = "选择一名角色，令其获得一个额外的回合。"
}


tiancaijinfeng:addEffect(fk.EventPhaseStart, {
  anim_type = "support",
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player.phase == Player.Discard and
      not player.dead and player:hasSkill(self.name) and #player.room:getOtherPlayers(player, true) > 0
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local tos = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      targets = player.room:getOtherPlayers(player, true),
      skill_name = tiancaijinfeng.name,
      prompt = "#tiancaijinfeng",
      cancelable = true,
    })
    if #tos > 0 then
      event:setCostData(self, { tos = tos })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    if not to.dead then
      to:gainAnExtraTurn(true, tiancaijinfeng.name)
    end
  end,
})

return tiancaijinfeng